package com.itheima.functioninterface;

import java.util.function.Consumer;

/**
 * <h1>JDK内置消费型函数式接口Consumer</h1>
 *
 * @author <a href="11n_yd2h5e1jx8@dingtalk.com">叶世铭</a>
 * @since 2024/1/29
 */
public class ConsumerDemo {
    public static void main(String[] args) {
        String str = "hello Consumer";
        transform(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s.toUpperCase());
            }
        },str);

        transform(s -> System.out.println(s.toUpperCase()),str);

    }

    public static void transform(Consumer<String> consumer,String str) {
        consumer.accept(str);
    }
}
